package com.lizk.imgbed;

import com.lizk.imgbed.utils.UIUtils;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.util.Pair;

public class Main extends Application {
    @Override
    public void init() throws Exception {
        super.init();
    }



    @Override
    public void start(Stage primaryStage) throws Exception {

        FXMLLoader fl = new FXMLLoader();
        /*
            原始方式：Parent root = FXMLLoader.load(getClass().getResource("./sample.fxml"));
            如果打成jar包以后，上面的方法会获取不到资源文件，导致报错
            素以改为下面的方式加载ui配置文件
         */
        Parent root = fl.load(Controller.class.getResourceAsStream("sample.fxml"));

        Scene scene = new Scene(root, 40, 40);

        Pair<Integer, Integer> screenVisibleXY = UIUtils.getScreenVisibleXY();
        primaryStage.setX(screenVisibleXY.getKey() - 100);
        primaryStage.setY(100);

        primaryStage.initStyle(StageStyle.TRANSPARENT);

        primaryStage.setScene(scene);
        primaryStage.setAlwaysOnTop(true);
        primaryStage.setTitle("极简图床");

        primaryStage.show();
    }


    public static void main(String[] args) {
        launch(args);
    }
}
